<?php
class Poll_AdminSettingsController extends Core_Controller_Action_Admin {   
	public function indexAction() {
        $this->view->navigation = $navigation = Engine_Api::_()->getApi('menus', 'core')
            ->getNavigation('poll_admin_main', array(), 'poll_admin_main_settings');
            
        $this->view->form = $form = new Poll_Form_Admin_Global();
        if (!$this->getRequest()->getPost() || !$form->isValid($this->getRequest()->getPost())) return;
        
        $values = $form->getValues();
        $api = Engine_Api::_()->getApi('settings', 'core');
        foreach ($values as $key => $value){
            $api->setSetting($key, $value);
        }
        $form->addNotice('Your changes have been saved.');
	}
}
